package com.zheng.study.web.controller.main.menu;

import cn.hutool.core.util.StrUtil;
import com.zheng.study.web.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * 菜单栏连接跳转
 * ============================================================================
 * author : fallenpanda
 * createDate:  2016-08-01 。
 * ============================================================================
 */
@Controller
@RequestMapping(value = "/main/menu")
public class MenuController extends BaseController {
	private static final long serialVersionUID = 6797762677360351191L;

	/**
	 * 菜单路由（一层菜单）
	 */
	@RequestMapping(value = "{menu}", method = RequestMethod.GET)
	public String menu(Model model, @PathVariable String menu, String type){
		model.addAttribute("type", type);
		addItem(model, menu);
		return "/main/menu/"+menu;
	}

	/**
	 * 菜单路由（二层菜单）
	 */
	@RequestMapping(value = "{menu1}/{menu2}", method = RequestMethod.GET)
	public String menu(Model model, String viewtype, String parentId, @PathVariable String menu1, @PathVariable String menu2){
		model.addAttribute("viewtype", viewtype);
		model.addAttribute("parentId", parentId);
		addItem(model, menu2);
		return "/main/menu/"+menu1+"/"+menu2;
	}

	private void addItem(Model model, String name){
		if(StrUtil.equals("dict", name)){

		}
	}

}
